<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/main.css"/>
    <script src="/layui/layui.js"></script>
    <script src="/js/jquery.1.8.3.min.js"></script>
    <link rel="stylesheet" href="/css/public.css" />
    <link rel="stylesheet" href="/css/signin.css" />
</head>
<body>

<div th:include="/common/courierHead :: head"></div>

<div class="content">


    <div class="user_info">
        <div>
            <div class="top flex flex-align-end flex-pack-center flex-warp">
                <div class="out-1 flex flex-align-center flex-pack-center" id="signIn">
                    <div class="out-2 flex flex-align-center flex-pack-center">
                        <div class="signBtn">
                            <strong id="sign-txt">签到</strong>
                            <span>累计<em id="sign-count">0</em>天</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tips">请假</div>
            <div class="Calendar">
                <div id="toyear" class="flex flex-pack-center">
                    <div id="idCalendarPre">&lt;</div>
                    <div class="year-month">
                        <span id="idCalendarYear">2018</span>年<span id="idCalendarMonth">6</span>月
                    </div>
                    <div id="idCalendarNext">&gt;</div>
                </div>
                <table border="1px" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr class="tou">
                        <td>日</td>
                        <td>一</td>
                        <td>二</td>
                        <td>三</td>
                        <td>四</td>
                        <td>五</td>
                        <td>六</td>
                    </tr>
                    </thead>
                    <tbody id="idCalendar">
                    </tbody>
                </table>
            </div>
            <script type="text/javascript" src="/js/rili.js"></script>
            <script language="JavaScript">
                var isSign = false;
                var myday = new Array(); //已签到的数组

                $.ajax({
                    url: '/courier/getWorkingArray',
                    method: 'GET',
                    async: false
                }).success(function(data){
                    console.log(data);


                    for (var i=0; i<data.length; i++) {
                        myday[i]=data[i];
                    }
                });

                console.log(myday);


                var cale = new Calendar("idCalendar", {
                    qdDay: myday,
                    onToday: function(o) {
                        o.className = "onToday";
                    },
                    onSignIn: function (){
                        $$("sign-txt").innerHTML = '已签到';
                    },
                    onFinish: function() {
                        $$("sign-count").innerHTML = myday.length //已签到次数
                        $$("idCalendarYear").innerHTML = this.Year;
                        $$("idCalendarMonth").innerHTML = this.Month; //表头年份

                    }
                });
                $$("idCalendarPre").onclick = function() {
                    cale.PreMonth();
                }
                $$("idCalendarNext").onclick = function() {
                    cale.NextMonth();
                }
                //添加今天签到
                $$("signIn").onclick = function() {
                    if(isSign == false) {
                        var res = cale.SignIn();
                        $.get("/courier/changeState",function (e) {

                        })
                        if(res == '1') {
                            $$("sign-txt").innerHTML = '已签到';
                            $$("sign-count").innerHTML = parseInt($$("sign-count").innerHTML) + 1;
                            isSign = true;


                        } else if (res == '2'){
                            $$("sign-txt").innerHTML = '已签到';
                            alert('今天已经签到了')
                        }
                    } else {
                        alert('今天已经签到了')
                    }

                }
            </script>

        </div>
    </div>




</div>

<div th:include="/common/footer :: footer"></div>


<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
</body>
</html>